#include <iostream>
#include <cstdlib>

class Test
{
public:
    Test()
    {
        p = new int;
        std::cout<<"构造函数\n";
    }

    Test(const Test & t)
    {
        std::cout<<"拷贝构造\n";
        p = new int;
        *p = *t.p;
    }

    ~Test()
    {
        delete p;
        std::cout<<"析构函数\n";
    }
private:
    int *p;
};

Test func(Test & t)
{
    return t;
}

int main()
{
    //Test();//匿名对: 即构造又析构,生命周期只有一行代码;
    //Test t = Test();//一次构造，一次析构
    Test t;
    Test t1 = func(t);
    return 0;
}